<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"vchao.top","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}};
  </script>

  <meta name="description" content="特此记录经验教训用作分享，希望大家涉及到此部分时，少走弯路。 问题描述： 经过客户反馈，oppo，vivo若干机型无法播放视频。(代表机型oppo a59s和oppo r7s)身边没有上述两个机型，采用oppo r11测试，一切正常。  无法测试，只能梳理代码，寻找原因  项目描述：采用视频播放框架Vitamio  查询两款手机系统信息。 OPPO A59s 出厂操作系统    ColorOS 3">
<meta property="og:type" content="article">
<meta property="og:title" content="记一次适配bug解决过程，权用作经验教训分享">
<meta property="og:url" content="http://vchao.top/2021/08/25/%E8%AE%B0%E4%B8%80%E6%AC%A1%E9%80%82%E9%85%8Dbug%E8%A7%A3%E5%86%B3%E8%BF%87%E7%A8%8B%EF%BC%8C%E6%9D%83%E7%94%A8%E4%BD%9C%E7%BB%8F%E9%AA%8C%E6%95%99%E8%AE%AD%E5%88%86%E4%BA%AB/index.html">
<meta property="og:site_name" content="乘风破浪">
<meta property="og:description" content="特此记录经验教训用作分享，希望大家涉及到此部分时，少走弯路。 问题描述： 经过客户反馈，oppo，vivo若干机型无法播放视频。(代表机型oppo a59s和oppo r7s)身边没有上述两个机型，采用oppo r11测试，一切正常。  无法测试，只能梳理代码，寻找原因  项目描述：采用视频播放框架Vitamio  查询两款手机系统信息。 OPPO A59s 出厂操作系统    ColorOS 3">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://img-blog.csdnimg.cn/20190429175133271.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3poZW5nX3dlaWNoYW8=,size_16,color_FFFFFF,t_70">
<meta property="article:published_time" content="2021-08-25T14:42:51.255Z">
<meta property="article:modified_time" content="2021-08-25T14:37:20.816Z">
<meta property="article:author" content="vchao">
<meta property="article:tag" content="Android">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://img-blog.csdnimg.cn/20190429175133271.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3poZW5nX3dlaWNoYW8=,size_16,color_FFFFFF,t_70">

<link rel="canonical" href="http://vchao.top/2021/08/25/%E8%AE%B0%E4%B8%80%E6%AC%A1%E9%80%82%E9%85%8Dbug%E8%A7%A3%E5%86%B3%E8%BF%87%E7%A8%8B%EF%BC%8C%E6%9D%83%E7%94%A8%E4%BD%9C%E7%BB%8F%E9%AA%8C%E6%95%99%E8%AE%AD%E5%88%86%E4%BA%AB/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>记一次适配bug解决过程，权用作经验教训分享 | 乘风破浪</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">乘风破浪</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档</a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://vchao.top/2021/08/25/%E8%AE%B0%E4%B8%80%E6%AC%A1%E9%80%82%E9%85%8Dbug%E8%A7%A3%E5%86%B3%E8%BF%87%E7%A8%8B%EF%BC%8C%E6%9D%83%E7%94%A8%E4%BD%9C%E7%BB%8F%E9%AA%8C%E6%95%99%E8%AE%AD%E5%88%86%E4%BA%AB/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.gif">
      <meta itemprop="name" content="vchao">
      <meta itemprop="description" content="怀揣好奇，梦想改变世界的菜鸟极客">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="乘风破浪">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          记一次适配bug解决过程，权用作经验教训分享
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>
              

              <time title="创建时间：2021-08-25 22:42:51 / 修改时间：22:37:20" itemprop="dateCreated datePublished" datetime="2021-08-25T22:42:51+08:00">2021-08-25</time>
            </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Android/" itemprop="url" rel="index"><span itemprop="name">Android</span></a>
                </span>
            </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>特此记录经验教训用作分享，希望大家涉及到此部分时，少走弯路。</p>
<h2 id="问题描述："><a href="#问题描述：" class="headerlink" title="问题描述："></a>问题描述：</h2><ul>
<li><p>经过客户反馈，oppo，vivo若干机型无法播放视频。(代表机型oppo a59s和oppo r7s)<br>身边没有上述两个机型，采用oppo r11测试，一切正常。</p>
</li>
<li><p>无法测试，只能梳理代码，寻找原因</p>
</li>
<li><p>项目描述：采用视频播放框架Vitamio</p>
</li>
<li><p>查询两款手机系统信息。</p>
<p><strong>OPPO A59s</strong></p>
<p>出厂操作系统    ColorOS 3.0 （基于Android 5.1）<br>CPU型号    联发科 MT6750</p>
<p><strong>OPPO R7s</strong></p>
<p>出厂操作系统    Color OS 2.1（基于Android 5.1）<br>CPU型号    高通 骁龙Snapdragon MSM8939</p>
<blockquote>
<p>手机信息查询网址有很多， 在此推荐：<a target="_blank" rel="noopener" href="http://www.zol.com.cn/">http://www.zol.com.cn/</a></p>
</blockquote>
</li>
</ul>
<h2 id="解决历程："><a href="#解决历程：" class="headerlink" title="解决历程："></a>解决历程：</h2><p>（以下方法均未解决问题，此处记录仅用作发散思维）</p>
<ol>
<li><p>首先确定是否是账号问题，交叉测试后排除该原因。</p>
</li>
<li><p>查看是否是so库问题。</p>
<p>查看项目中lib库中的so文件，其中共包括armeabi, armeabi-v7a, x86, mips，分析后并无问题。</p>
<p><strong>科普：</strong></p>
<blockquote>
<p>应用程序二进制接口（Application Binary Interface）定义了二进制文件（尤其是.so文件）如何运行在相应的系统平台上，从使用的指令集，内存对齐到可用的系统函数库。在Android系统上，每一个CPU架构对应一个ABI：armeabi，armeabi-v7a，x86，mips，arm64-v8a，mips64，x86_64。</p>
<p><strong>如果项目只包含了 armeabi，那么在所有Android设备都可以运行；</strong></p>
<p><strong>如果项目只包含了 armeabi-v7a，除armeabi 架构的设备外都可以运行；</strong> </p>
<p><strong>如果项目只包含了 x86，那么armeabi架构和armeabi-v7a的Android设备是无法运行的；</strong> </p>
<p><strong>如果同时包含了 armeabi， armeabi-v7a和x86，所有设备都可以运行，</strong></p>
<p>程序在运行的时候去加载不同平台对应的so，这是较为完美的一种解决方案，同时也会导致包变大。</p>
<p>目前主流的Android设备是armeabi-v7a架构的，然后就是x86和armeabi了。</p>
</blockquote>
</li>
<li><p>因为是无法播放视频，所以查看视频播放框架特性，及是否有机型不支持问题。查到数据如下：<br><a target="_blank" rel="noopener" href="https://www.vitamio.org/docs/Basic/2013/0508/13.html">Vitamio不支持特性列表</a></p>
</li>
</ol>
<p><img src="https://img-blog.csdnimg.cn/20190429175133271.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3poZW5nX3dlaWNoYW8=,size_16,color_FFFFFF,t_70" alt="Vitamio不支持特性列表"></p>
<p>其中第1点，第7点，第8点，第14点需要引起注意。</p>
<p>我也花费了大量的时间和精力在这部分内容上，进行了多处包裹异常，以及机型判断，结果并无实质性改变。</p>
<p><strong>科普：</strong></p>
<blockquote>
<p>早期的Android系统几乎只支持ARMv5的CPU架构，现在Android系统支持以下七种不同的CPU架构：ARMv5，ARMv7 (从2010年起)，x86 (从2011年起)，MIPS (从2012年起)，ARMv8，MIPS64和x86_64 (从2014年起)，每一种都关联着一个相应的ABI。</p>
</blockquote>
<h2 id="最终解决"><a href="#最终解决" class="headerlink" title="最终解决"></a>最终解决</h2><p>找到了一部oppo  a53m手机，经测试，重现了客户提到的问题。遂委托同事进行日志查看。</p>
<p>报错信息如下：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">java. lang. NoSuchMethodError:<span class="function">No virtual method <span class="title">getColor</span><span class="params">(I)</span>I in class Landroid/content/Context</span>; <span class="function">or its <span class="keyword">super</span> <span class="title">classes</span> <span class="params">(declaration of<span class="string">&#x27; android. content. Context&#x27;</span> appears in /system/frameworlk/franework. jar)</span></span></span><br><span class="line"><span class="function">at com sxmh. wt. education. adapter. lesson. RoWatchlessonlisthdapter. <span class="title">onBindViewHolder</span><span class="params">(RviWatchlessonl istAdapter. java:<span class="number">54</span>)</span></span></span><br><span class="line"><span class="function">at com sxh. wt. educationadapter. lesson. RvTatchlessonlistAdapter. <span class="title">onBindviewHolder</span><span class="params">(RvWatchlessonl istidapter. java:<span class="number">23</span>)</span></span></span><br></pre></td></tr></table></figure>

<p>轻易可得：问题出现在设置颜色时，低版本系统无此方法。问题代码如下：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">holder.tvTitle.setTextColor(context.getColor(R.color.colorTextRed));</span><br></pre></td></tr></table></figure>

<p><strong>解决办法：</strong></p>
<p>修改为兼容低版本系统的方法。两种任选其一即可，如下：</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 该方法可以解决问题，但是不推荐</span></span><br><span class="line">holder.tvTitle.setTextColor(context.getResources().getColor(R.color.colorTextRed));</span><br></pre></td></tr></table></figure>

<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 推荐写法，兼容性更好</span></span><br><span class="line">holder.tvTitle.setTextColor(ContextCompat.getColor(context, R.color.colorTextRed));</span><br></pre></td></tr></table></figure>


<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><ul>
<li>一句代码就可能弄丢项目，导致公司的业务方向受损，代码开发，应仔细认真。</li>
<li>安卓机型适配问题十分复杂，最好找到同款或者相似机型，能复现问题后再做处理。</li>
<li>平常写代码，应多注意适配问题。本问题即为常见的适配问题，注意书写即可避免。</li>
<li>代码bug原因关联很多，不能死盯一处，处理问题的方向错了，怎么解决也无济于事。</li>
</ul>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/tags/Android/" rel="tag"># Android</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/08/25/%E7%BB%99APP%E4%B8%8A%E4%BB%BD%E4%BF%9D%E9%99%A9%EF%BC%9A%E5%AE%89%E5%8D%93%E7%9A%84%E5%85%A8%E5%B1%80%E5%BC%82%E5%B8%B8%E6%8D%95%E8%8E%B7/" rel="prev" title="给APP上份保险：安卓的全局异常捕获">
      <i class="fa fa-chevron-left"></i> 给APP上份保险：安卓的全局异常捕获
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/08/25/%E8%B0%88%E8%B0%88%E5%AE%89%E5%8D%93%E4%B8%ADContext%E7%9A%84%E7%90%86%E8%A7%A3%5B%E9%99%84%E6%80%9D%E7%BB%B4%E5%AF%BC%E5%9B%BE%5D/" rel="next" title="谈谈安卓中Context的理解[附思维导图]">
      谈谈安卓中Context的理解[附思维导图] <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E9%97%AE%E9%A2%98%E6%8F%8F%E8%BF%B0%EF%BC%9A"><span class="nav-number">1.</span> <span class="nav-text">问题描述：</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E8%A7%A3%E5%86%B3%E5%8E%86%E7%A8%8B%EF%BC%9A"><span class="nav-number">2.</span> <span class="nav-text">解决历程：</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%9C%80%E7%BB%88%E8%A7%A3%E5%86%B3"><span class="nav-number">3.</span> <span class="nav-text">最终解决</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%80%BB%E7%BB%93"><span class="nav-number">4.</span> <span class="nav-text">总结</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">vchao</p>
  <div class="site-description" itemprop="description">怀揣好奇，梦想改变世界的菜鸟极客</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">46</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
        <span class="site-state-item-count">4</span>
        <span class="site-state-item-name">分类</span>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">27</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        
  <div class="beian"><a href="https://beian.miit.gov.cn/" rel="noopener" target="_blank">冀ICP备 17022751号-1 </a>
      <img src="https://beian.miit.gov.cn" style="display: inline-block;">
  </div>

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2021</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">vchao</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  

</body>
</html>
